package com.lkd.controller;

import com.lkd.dto.RegionDto;
import com.lkd.entity.Region;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.RegionService;
import com.lkd.vo.NodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//分类管理
@RestController
public class RegionController {

    @Autowired
    private RegionService regionService;

    //分页查询
    @GetMapping("/api/vm-service/region/search")
    public Result findByPage(RegionDto regionDto){
        PageBean pageBean = regionService.findByPage(regionDto);
        return Result.success(pageBean);
    }

    //新增
    @PostMapping("/api/vm-service/region")
    public Result save(@RequestBody Region region){
        Boolean result = regionService.save(region);
        return Result.success(result);
    }

    //查看区域详情
    @GetMapping("/api/vm-service/node/search")
    public Result findNodeByRegionId(RegionDto regionDto){
        PageBean<NodeVo> pageBean = regionService.findNodeByRegionId(regionDto);
        return Result.success(pageBean);
    }

    //修改
    @PutMapping("/api/vm-service/region")
    public Result update(@RequestBody Region region){
        Boolean result = regionService.update(region);
        return Result.success(result);
    }

}
